package game;

import java.io.IOException;
import java.io.InputStream;

import javax.microedition.lcdui.*;
import javax.microedition.m2g.*;

/**
 * This class handles all things which have to be done for a pretty nice menu!
 * @author Gustav
 * @since 26.4.2010
 */
public class Menu {
	
	private SVGImage svgImage;
	private SVGAnimator svgAnimator;
	private Canvas svgCanvas;
        private MIDPSVGEventListener listener;

        /**
         * One-time initialization
         */
        public Menu(){
            InputStream is = getClass().getResourceAsStream("/animate.svg");
            try {
                     svgImage = (SVGImage)SVGImage.createImage(is, null);
            } catch (IOException e) {
                    e.printStackTrace();
                System.out.println("Could not load image!");
            }
            svgAnimator = SVGAnimator.createAnimator(svgImage);
            //hier wird der canvas ausgetauscht
            listener = new MIDPSVGEventListener(svgAnimator, svgImage);
            svgAnimator.setSVGEventListener(listener);
            svgCanvas = (Canvas)svgAnimator.getTargetComponent();
            svgCanvas.setFullScreenMode(true);
        }

        /**
         * show... show it... show it all the times... muhihi
         */
	public void start(){
            svgAnimator.play();
            Display.getDisplay(LUMM2_Canvas.midlet).setCurrent(svgCanvas);
	}
}
